#pragma once

#include "cFile.h"

#define OUT

class cFileRaw : public cFile
{
public:
	friend class cFileManager;

	virtual eFile::TYPE GetType() { return eFile::RAW; }
	
	virtual tInt Seek(tInt offset, eFileSeek::TYPE seek);
	virtual tUInt Tell();
	virtual tInt Eof();
    virtual tInt GetPosition() { return m_readPos; }
	virtual tChar* GetBuffer() { return m_readBuffer + m_readPos; }

	virtual tUInt Read(void *data, tInt data_len);
	virtual void Write(void *data, tInt data_len);

	virtual tChar* Gets(tChar *str, tInt str_len);
	virtual void Puts(const tChar *str);


	static void Init();
	static void Finish();

//protected:
	cFileRaw();
	virtual ~cFileRaw();

	virtual tBool Open(const tString& fullpath, eFileMode::TYPE mode, tBool alloc);
	virtual void Close();

	static tBool Access(const tString& fullpath);
	static tBool Dump(const tString& fullpath, eFileMode::TYPE mode, tBool alloc, OUT tChar** pp_buffer, OUT tInt& size);
	static tInt Size(FILE* fp);

private:
	FILE* m_fp;
	tBool m_preRead;

	tChar* m_readBuffer;
	tInt m_readPos;

	static tChar* ms_dump_buffer;
	static tInt ms_dump_size;
};
